<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>登录</title>
		<link rel="stylesheet" type="text/css" href="css/main.css" />
		
		<style>
			html,body{
				padding:0;
				margin:0;
				height:100%;
				width:100%;
			}
		</style>
		
	</head>
	
	<body>
		
		<div class="logininfo">
			<div class="loginbox">
				<form action="" method="get"  enctype='multipart/form-data'>
					<div class="loginmain">
						<table width="100%" cellspacing="0">
							<tr style="margin-bottom: 20px;">
								<td width="10%" >
									<i class="iconfont loginicon">&#xe654;</i>
								</td>
								<td width="90%">
									<input type="text" placeholder="请输入用户名" name="username" id="username" class="logininput" />
									<p class="prompt"></p>
								</td>
							</tr>
							
							<tr>
								<td width="10%" >
									<i class="iconfont loginicon" style="top: 15px;position: relative;">&#xe61c;</i>
								</td>
								<td width="90%">
									<input type="password" placeholder="请输入密码" name="password" id="password" class="logininput ma-to-30" />
								</td>
							</tr>
							
							<tr>
								<td colspan="2" align="center">
									<button type="button" onclick="getLogin()" class="loginbtn">登录</button>
								</td>
							</tr>
						</table>
					</div>
				</form>
			</div>
		</div>
		
	</body>
	
	<script src="http://www.jq22.com/jquery/jquery-1.9.1.js"></script>
	<script src="../mobile/js/jquery.cookie.js"></script>
	
	<script>
		
		
	var username=$.cookie("username");
	var psd=$.cookie("psd");


	$('#username').val(username);
	$('#password').val(psd);


	$('#username').mousemove(function () {
		$('#username').focus();
	});

	$('#password').mousemove(function () {
		$('#password').focus();
	});


	function getLogin(){

		//var url="http://wifi.qianlh.com";
		var url="http://192.168.0.132:69";

		var geturl=url+ "/admin/adminapi/adminlogin";

		var username=$('#username').val();

		var psd=$('#password').val();

		if(username==""){
			alert("请输入登录账号");
			$('#username').focus();
			return false;
		}else if(psd==""){
			alert("请输入登录密码");
			$('#username').focus();
			return false;
		}


		$.ajax({
			type: 'get',
			dataType: "json",
			url: geturl + '?nickname=' + username+"&password="+psd,
			success: function (data) {
				//console.log(data);
				//return false;
				var suc=data.success;
				var name=data.tooken;


				if(suc.code == 4007){
					alert(suc.message);
					return false;
				}else if(suc.code == 4012){
					alert(suc.message);
					return false;
				}else if(suc.code == 4000){

					//$.cookie('level', ''+ data.level +'',{expires: 3});
					$.cookie('tooken', ''+ name +'',{expires: 3,path:'/'});
					var tooken=$.cookie("tooken");

					$.cookie('username', ''+ username +'',{expires: 3,path:'/'});
					$.cookie('psd', ''+ psd +'',{expires: 3,path:'/'});

					window.location.href="index.html";




				}

			},error:function(data){
				console.log("请检查您的网络");
			}
		});

	}

		
	</script>
	
</html>
